<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class RegisterPost extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $rule = [
            'mobile'=>'bail|required|min:11|max:11|unique:users,mobile',
            'password'=>'required'
        ];
        return $rule;
    }

    /**
     * 获取已定义的验证规则的错误消息。
     *
     * @return array
     */
    public function messages()
    {
        return [
            'mobile.required' => '手机号码不能为空',
            'mobile.min' => '请检查手机号长度是否是11位',
            'mobile.max' => '请检查手机号长度是否是11位',
            'mobile.unique' => '手机号码已存在',
            'password.required'  => '密码不能为空',
        ];
    }

}
